<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="include :: header('修改轮播图信息')" />
<th:block th:include="include :: datetimepicker-css" />
<th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-banner-edit"
			th:object="${sysAppBanner}">
			<input name="id" th:field="*{id}" type="hidden">
			<div class="form-group">
				<label class="col-sm-3 control-label">标题：</label>
				<div class="col-sm-8">
					<input name="imgTitle" th:field="*{imgTitle}" class="form-control"
						type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">图片访问地址：</label>
				<div class="col-sm-8">
					<input name="imgUrl" th:field="*{imgUrl}" class="form-control"
						type="text">
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">是否跳转：</label>
				<div class="col-sm-9">
					<label class="radio-box"> <input type="radio"
						id="optionsRadios1" value="0" th:field="*{skipType}"
						name="skipType">不跳转
					</label> <label class="radio-box"> <input type="radio"
						id="optionsRadios2" value="1" th:field="*{skipType}"
						name="skipType">跳转
					</label>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">是否启用：</label>
				<div class="col-sm-9">
					<label class="radio-box"> <input type="radio"
						id="optionsRadios3" value="0" th:field="*{isEnable}"
						name="isEnable">未启用
					</label> <label class="radio-box"> <input type="radio"
						id="optionsRadios4" value="1" th:field="*{isEnable}"
						name="isEnable">启用
					</label>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">排序：</label>
				<div class="col-sm-8">
					<input name="num" th:field="*{num}" class="form-control"
						type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">图片描述：</label>
				<div class="col-sm-8">
					<input name="describeinfo" th:field="*{describeinfo}"
						class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
                <label class="col-sm-3 control-label">图片上传：</label>
                <div class="col-sm-8">
                    <input name="url" class="form-control" type="file"  onchange="uploadFile('url')">
                    <input id="imgLink" name="imgLink" th:field="*{imgLink}" class="form-control" type="hidden">
                </div>
            </div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: datetimepicker-js" />
	<th:block th:include="include :: bootstrap-fileinput-js" />
	<script th:inline="javascript">
        var prefix = ctx + "system/banner";
        $("#form-banner-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-banner-edit').serialize());
            }
        }

        $("input[name='creatTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        
        function uploadFile(filePath) {
            var formData = new FormData();
            if ($("input[name='" + filePath + "']")[0].files[0] == null) {
                $.modal.alertWarning("请先选择文件路径");
                return false;
            }
            formData.append('file', $("input[name='" + filePath + "']")[0].files[0]);
            $.ajax({
            	url: ctx + "common/upload",
                type: 'post',
                cache: false,
                data: formData,
                processData: false,
                contentType: false,
                dataType: "json",
                success: function (result) {
                	if (result.code == web_status.SUCCESS) {
                		$("#imgLink").val(result.url);
					} else {
						$.modal.alertError(result.msg);
					}
                    
                }
            });
        }
    </script>
</body>
</html>